/*
 * CommandLineProcessor.h
 *
 *  Created on: 19/03/2011
 *      Author: ehpalumbo
 */

#ifndef COMMANDLINEPROCESS_H_
#define COMMANDLINEPROCESS_H_

#include <string>
#include <map>
#include <set>
#include <iostream>


using namespace std;


namespace CommandLineProcess {


class Tag {
private:
	bool required;
	string* tagName;
public:
	Tag(string& tagName, bool required);
	bool isRequired();
	string& getName();
	virtual ~Tag();
};


class ArgumentHandler {
private:
	Tag* tag;
	string* description;
public:
	ArgumentHandler(Tag& aTag, string& aDescription);
	Tag& getTag();
	string& getDescription();
	virtual bool handleArgument(string& argument) =0;
	virtual ~ArgumentHandler();
};


class CommandLineProcessor {
protected:
	ostream* output;
	map<string, ArgumentHandler*>* handlerByTagNameMap;
	set<string>* requiredTagNames;
	virtual void onUnknownParameter(const string& parameter);
	virtual void onNotEnoughParameters();
	virtual void onNotParameters();
public:
	CommandLineProcessor(ostream& output);
	virtual bool processArguments(int argc, const char* argv[]);
	void registerArgumentHandler(ArgumentHandler& argHandler);
	virtual void printHelp();
	virtual ~CommandLineProcessor();
};


}

#endif /* COMMANDLINEPROCESS_H_ */
